//
//  HCStatus.swift
//  Hweibome
//
//  Created by 何川 on 15/12/10.
//  Copyright © 2015年 hechuan. All rights reserved.
//

import UIKit

class HCStatus: NSObject {

    var id: Int64 = 0
    var text:String?
    var user:HCUser?
    var created_at: String?
    var source:String?
    var reposts_count: Int = 0
    var comments_count: Int = 0
    var attitudes_count: Int = 0
    //转发微博内容
    var retweeted_status: HCStatus?
    //当前微博配图
    var pic_urls: [HCStatusPictureInfo]?
      
    
    init (dict:[String: AnyObject])
    {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            if let dict = value as? [String:AnyObject] {
                user = HCUser(dict: dict)
            }
        }else if key == "retweeted_status" {
                if let dict = value as? [String:AnyObject] {
                    retweeted_status = HCStatus(dict: dict)
                }
            }else if key  == "pic_urls"
        {
            if let array = value as? [[String:AnyObject]]{
                var tempArray = [HCStatusPictureInfo]()
                for dict in array {
                    tempArray.append(HCStatusPictureInfo(dict: dict))
                }
                pic_urls = tempArray
            }
        }
            else{
                super.setValue(value, forKey: key)
            }
            
        
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description: String
    {
            let keys = ["text","retweeted_status"]
            return dictionaryWithValuesForKeys(keys).description
    }
}
